<template>
  <div>
    <h1>
      玉林师范学院
      <el-input
        size="small"
        style="width: 80px; padding: 0"
        v-model="formInline.SecondaryCollege"
        v-if="infoShow"
      ></el-input>
      <span v-else>{{ formInline.SecondaryCollege }}</span>
      学院<el-input
        size="small"
        style="width: 80px"
        v-model="formInline.className"
        v-if="infoShow"
      ></el-input
      ><span v-else>{{ formInline.className }}</span
      >学生<el-input
        size="small"
        style="width: 80px"
        v-model="formInline.schoolYear"
        v-if="infoShow"
      ></el-input
      ><span v-else>{{ formInline.schoolYear }}</span
      >学年度第
      <el-input
        size="small"
        style="width: 80px"
        v-model="formInline.semester"
        v-if="infoShow"
      ></el-input
      ><span v-else>{{ formInline.semester }}</span
      >学期德智体综合测评量化评分表
    </h1>
    <div class="form">
      <el-form
        size="mini"
        :inline="true"
        :model="formInline"
        class="demo-form-inline"
      >
        <el-form-item label="姓名：">
          <el-input
            style="width: 100px"
            v-model="formInline.studentName"
            v-if="infoShow"
          ></el-input>
          <span v-else>{{ formInline.studentName }}</span>
        </el-form-item>
        <el-form-item label="学号：">
          <el-input
            style="width: 120px"
            v-model="formInline.studentNo"
            v-if="infoShow"
          ></el-input>
          <span v-else>{{ formInline.studentNo }}</span>
        </el-form-item>
        <el-form-item label="年级：">
          <el-input
            style="width: 80px"
            v-model="formInline.grade"
            v-if="infoShow"
          ></el-input>
          <span v-else>{{ formInline.grade }}</span>
        </el-form-item>
      </el-form>
    </div>
    <el-button type="info" @click="add" :disabled="!infoShow"
      >添加一行</el-button
    >
    <el-table
      :data="tableData"
      :fit="true"
      border
      style="width: 100%"
      :cell-style="cellStyle"
      :header-cell-style="headerCellStyle"
    >
      <el-table-column :label="tableList.number">
        <template slot-scope="scope">
          <span style="margin-left: 10px" v-if="scope.row.show">{{
            scope.row.numberNo
          }}</span>
          <el-input
            style="width: 50px"
            size="small"
            disabled
            v-model="scope.row.numberNo"
            v-else
          ></el-input>
        </template>
      </el-table-column>
      <el-table-column :label="tableList.jiafen">
        <template slot-scope="scope">
          <span style="margin-left: 10px" v-if="scope.row.show">{{
            scope.row.jia
          }}</span>
          <el-input
            type="textarea"
            autosize
            v-model="scope.row.jia"
            v-else
          ></el-input>
        </template>
      </el-table-column>
      <el-table-column :label="tableList.jianfen">
        <template slot-scope="scope">
          <span style="margin-left: 10px" v-if="scope.row.show">{{
            scope.row.jian
          }}</span>

          <el-input type="textarea" autosize v-model="scope.row.jian" v-else>
          </el-input>
        </template>
      </el-table-column>
      <el-table-column :label="tableList.de">
        <template slot-scope="scope">
          <span style="margin-left: 10px" v-if="scope.row.show">{{
            scope.row.DE
          }}</span>
          <el-input size="small" v-model="scope.row.DE" v-else></el-input>
        </template>
      </el-table-column>
      <el-table-column :label="tableList.zhi">
        <template slot-scope="scope">
          <span style="margin-left: 10px" v-if="scope.row.show">{{
            scope.row.ZHI
          }}</span>
          <el-input size="small" v-model="scope.row.ZHI" v-else></el-input>
        </template>
      </el-table-column>
      <el-table-column :label="tableList.ti">
        <template slot-scope="scope">
          <span style="margin-left: 10px" v-if="scope.row.show">{{
            scope.row.TI
          }}</span>
          <el-input size="small" v-model="scope.row.TI" v-else></el-input>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            :disabled="!infoShow"
            size="mini"
            @click="handleEdit(scope.$index, scope.row)"
            >{{ scope.row.show ? "编辑" : "保存" }}</el-button
          >
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
            :disabled="!infoShow"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <template>
      <el-form
        size="mini"
        :inline="true"
        :model="calculationScore"
        class="demo-form-inline"
        style="background: #fff; padding: 12px 0"
      >
        <div style="color: red; font-size: 12px; margin: 0 0 10px 0">
          注：(本次自动计算按照（德育基本分+德育分）*0.3
          （智育育基本分+智育育分）*0.5
          （体育基本分+体育分）*0.2来计算。如果不符合要求，也可以手动计算，例如：（70+12）*0.3或85*0.5形式输入计算，切记括号为英文括号
          )
        </div>
        <div class="scoreForm">
          <el-form-item
            label="德育基本分:"
            style="display: flex; flex-direction: column; align-items: center"
          >
            <el-input
              style="width: 50px"
              v-model="scoreList.moralEducation.DeBasicScore"
              v-if="infoShow"
            ></el-input>
            <span v-else>{{ scoreList.moralEducation.DeBasicScore }}</span>
          </el-form-item>
          <el-form-item
            label="德育分:"
            style="display: flex; flex-direction: column; align-items: center"
          >
            <el-input
              style="width: 50px"
              v-model="scoreList.moralEducation.moralEducationScore"
              v-if="infoShow"
            ></el-input>
            <span v-else>{{
              scoreList.moralEducation.moralEducationScore
            }}</span>
          </el-form-item>
          <el-form-item
            label="德育总分:"
            style="display: flex; flex-direction: column; align-items: center"
          >
            <el-input
              style="width: 80px"
              v-model="scoreList.moralEducation.TotalScore"
              @blur="deTotal"
              v-if="infoShow"
            ></el-input>
            <span v-else>{{ scoreList.moralEducation.TotalScore }}</span>
          </el-form-item>

          <el-form-item
            label="智育基本分:"
            style="display: flex; flex-direction: column; align-items: center"
          >
            <el-input
              style="width: 50px"
              v-model="scoreList.IntellectualEducation.ZhiBasicScore"
              v-if="infoShow"
            ></el-input>
            <span v-else>{{
              scoreList.IntellectualEducation.ZhiBasicScore
            }}</span>
          </el-form-item>
          <el-form-item
            label="智育分:"
            style="display: flex; flex-direction: column; align-items: center"
          >
            <el-input
              style="width: 50px"
              v-model="
                scoreList.IntellectualEducation.IntellectualEducationScore
              "
              v-if="infoShow"
            ></el-input>
            <span v-else>{{
              scoreList.IntellectualEducation.IntellectualEducationScore
            }}</span>
          </el-form-item>
          <el-form-item
            label="智育总分:"
            style="display: flex; flex-direction: column; align-items: center"
          >
            <el-input
              style="width: 80px"
              v-model="scoreList.IntellectualEducation.TotalScore"
              @blur="zhiTotal"
              v-if="infoShow"
            ></el-input>
            <span v-else>{{ scoreList.IntellectualEducation.TotalScore }}</span>
          </el-form-item>

          <el-form-item
            label="体育基本分:"
            style="display: flex; flex-direction: column; align-items: center"
          >
            <el-input
              style="width: 50px"
              v-model="scoreList.Sports.TiBasicScore"
              v-if="infoShow"
            ></el-input>
            <span v-else>{{ scoreList.Sports.TiBasicScore }}</span>
          </el-form-item>
          <el-form-item
            label="体育分:"
            style="display: flex; flex-direction: column; align-items: center"
          >
            <el-input
              style="width: 50px"
              v-model="scoreList.Sports.SportsScore"
              v-if="infoShow"
            ></el-input>
            <span v-else>{{ scoreList.Sports.SportsScore }}</span>
          </el-form-item>
          <el-form-item
            label="体育总分:"
            style="display: flex; flex-direction: column; align-items: center"
          >
            <el-input
              style="width: 80px"
              v-model="scoreList.Sports.TotalScore"
              @blur="tiTotal"
              v-if="infoShow"
            ></el-input>
            <span v-else>{{ scoreList.Sports.TotalScore }}</span>
          </el-form-item>
        </div>
        <template>
          <div style="display: flex" v-if="gradeClass">
            <el-form-item
              label="美育基本分:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 50px"
                v-model="scoreList.AestheticEducation.MeiBasicScore"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{
                scoreList.AestheticEducation.MeiBasicScore
              }}</span>
            </el-form-item>
            <el-form-item
              label="美育分:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 50px"
                v-model="scoreList.AestheticEducation.AestheticEducationScore"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{
                scoreList.AestheticEducation.AestheticEducationScore
              }}</span>
            </el-form-item>
            <el-form-item
              label="美育总分:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 80px"
                v-model="scoreList.AestheticEducation.TotalScore"
                @blur="meiTotal"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{ scoreList.AestheticEducation.TotalScore }}</span>
            </el-form-item>

            <el-form-item
              label="劳育基本分:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 50px"
                v-model="scoreList.LaborEducation.LaoBasicScore"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{ scoreList.LaborEducation.LaoBasicScore }}</span>
            </el-form-item>
            <el-form-item
              label="劳育分:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 50px"
                v-model="scoreList.LaborEducation.LaborEducationScore"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{
                scoreList.LaborEducation.LaborEducationScore
              }}</span>
            </el-form-item>
            <el-form-item
              label="劳育总分:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 80px"
                v-model="scoreList.LaborEducation.TotalScore"
                @blur="laoTotal"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{ scoreList.LaborEducation.TotalScore }}</span>
            </el-form-item>
            <el-form-item
              label="综合测评总分:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 80px"
                v-model="scoreList.ComprehensiveSurveyTotalScore"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{ scoreList.ComprehensiveSurveyTotalScore }}</span>
            </el-form-item>
            <el-form-item
              label="综合测评总分在班中名次:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 50px"
                v-model="scoreList.ComprehensiveSurveyRanking"
                v-if="infoShow"
                :readonly="true"
              ></el-input>
              <span v-else>{{ scoreList.ComprehensiveSurveyRanking }}</span>
            </el-form-item>

            <el-form-item
              label="班长签名:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 80px"
                v-model="scoreList.monitor"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{ scoreList.monitor }}</span>
            </el-form-item>
            <el-form-item
              label="班主任签名分:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 80px"
                v-model="scoreList.headmaster"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{ scoreList.headmaster }}</span>
            </el-form-item>
            <el-form-item
              label="辅导员签名:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 80px"
                v-model="scoreList.instructor"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{ scoreList.instructor }}</span>
            </el-form-item>
          </div>
          <div style="display: flex" v-else>
            <el-form-item
              label="综合测评总分:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 80px"
                v-model="scoreList.ComprehensiveSurveyTotalScore"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{ scoreList.ComprehensiveSurveyTotalScore }}</span>
            </el-form-item>
            <el-form-item
              label="综合测评总分在班中名次:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 50px"
                v-model="scoreList.ComprehensiveSurveyRanking"
                :readonly="true"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{ scoreList.ComprehensiveSurveyRanking }}</span>
            </el-form-item>

            <el-form-item
              label="班长签名:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 80px"
                v-model="scoreList.monitor"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{ scoreList.monitor }}</span>
            </el-form-item>
            <el-form-item
              label="班主任签名分:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 80px"
                v-model="scoreList.headmaster"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{ scoreList.headmaster }}</span>
            </el-form-item>
            <el-form-item
              label="辅导员签名:"
              style="display: flex; flex-direction: column; align-items: center"
            >
              <el-input
                style="width: 80px"
                v-model="scoreList.instructor"
                v-if="infoShow"
              ></el-input>
              <span v-else>{{ scoreList.instructor }}</span>
            </el-form-item>
          </div>
          <div style="margin-bottom: 24px">
            <label for="beizhuError">各科成绩情况：</label>
            <el-input
              type="textarea"
              :rows="2"
              placeholder="请输入内容"
              v-model="scoreList.projectScore"
              :readonly="!infoShow"
            ></el-input>
          </div>
        </template>
      </el-form>
    </template>
    <span v-if="buttonShow">
      <el-button
        type="info"
        @click="calculation"
        :disabled="!infoShow"
        style="margin-right: 12px"
        >自动计算分数</el-button
      >
      <el-button type="info" @click="submit" :disabled="gradeSubmit"
        >提交表格</el-button
      >
    </span>
    <span v-else>
      <div v-if="isAdmin">
        <label for="beizhuError" style="color: red">班级管理员备注错误：</label>
        <el-input
          type="textarea"
          :rows="2"
          placeholder="请输入内容"
          v-model="textarea"
          :readonly="isAdmin ? true : false"
        >
        </el-input>
      </div>
      <el-popover placement="top" width="160" v-model="visible">
        <p>确定通过吗？</p>
        <div style="text-align: right; margin: 0">
          <el-button size="mini" type="text" @click="visible = false"
            >取消</el-button
          >
          <el-button
            type="primary"
            size="mini"
            @click="onAdminProcess"
            v-if="isAdmin"
            >确定</el-button
          >
          <el-button type="primary" size="mini" @click="onProcess" v-else
            >确定</el-button
          >
        </div>
        <el-button
          slot="reference"
          type="info"
          :style="adminProcess ? 'background: green' : ''"
          v-if="isAdmin"
          :disabled="adminDisabled"
          >审核通过</el-button
        >
        <el-button
          slot="reference"
          type="info"
          :style="isProcess ? 'background: green' : ''"
          v-else
          >通过</el-button
        >
      </el-popover>

      <el-button
        type="info"
        :style="adminNoProcess ? 'background: red' : ''"
        @click="onAdminNoProcess"
        v-if="isAdmin"
        :disabled="adminDisabled"
        >审核不通过</el-button
      >
      <el-button
        type="info"
        :style="isNoProcess ? 'background: red' : ''"
        @click="onNoProcess"
        v-else
        >不通过</el-button
      >
    </span>
    <div v-if="isAdmin ? false : isNoProcess">
      <label for="beizhuError" style="color: red">备注错误：</label>
      <el-input
        type="textarea"
        :rows="2"
        placeholder="请输入内容"
        v-model="textarea"
      >
      </el-input>
      <el-button type="info" @click="submit">确定</el-button>
    </div>
    <div v-else-if="adminNoProcess">
      <label for="beizhuError" style="color: red">备注错误：</label>
      <el-input
        type="textarea"
        :rows="2"
        placeholder="请输入内容"
        v-model="Admintextarea"
      >
      </el-input>
      <el-button type="info" @click="submit">确定</el-button>
    </div>
    <div v-if="isStudent" style="margin: 12px 0px 12px 0px">
      <div v-if="studentStatus">
        <el-button type="info" :style="isStudent ? 'background: red' : ''"
          >审核不通过</el-button
        >
        <div v-if="haveStudentTextarea">
          <label for="beizhuError" style="color: red"
            >班级管理员备注错误：</label
          >
          <el-input
            type="textarea"
            :rows="2"
            placeholder="请输入内容"
            v-model="textarea"
            :readonly="isStudent ? true : false"
          >
          </el-input>
        </div>
        <div v-else></div>
        <div v-if="haveAdmintextarea">
          <label for="adminbeizhuError" style="color: red"
            >学院管理员备注错误：</label
          >
          <el-input
            type="textarea"
            :rows="2"
            placeholder="请输入内容"
            v-model="Admintextarea"
            :readonly="isStudent ? true : false"
          >
          </el-input>
        </div>
        <div v-else></div>
      </div>
      <div v-else-if="status">
        <el-button
          slot="reference"
          type="info"
          :style="!isStudent ? 'background: green' : ''"
          >审核通过</el-button
        >
      </div>
      <div v-else>
        <div v-if="showWEI">
          <el-button slot="reference" type="info" style="background: orange"
            >未审核</el-button
          >
        </div>
        <div v-else></div>
      </div>
    </div>

    <div v-else></div>
  </div>
</template>

<script>
import Vue from "vue";
import { TableColumn, Table, Input, Button } from "element-ui";
Vue.use(TableColumn);
Vue.use(Table);
Vue.use(Input);
Vue.use(Button);
export default {
  name: "Freshman",
  props: ["count"],
  data() {
    const userInfo = JSON.parse(localStorage.getItem("userInfo"));
    return {
      adminDisabled: false,
      showWEI: false,
      haveStudentTextarea: false,
      haveAdmintextarea: false,
      status: false,
      studentStatus: false,
      isStudent: userInfo.isStudentManage === 0 ? true : false,
      isAdmin: userInfo.isStudentManage === 2 ? true : false,
      Admintextarea: "",
      adminProcess: false,
      adminNoProcess: false,
      cellStyle: {
        padding: "5px",
        textAlign: "center",
      },
      headerCellStyle: {
        textAlign: "center",
      },
      // 单元格数据
      tableData: [
        {
          numberNo: 1,
          jia: "",
          jian: "",
          DE: 0,
          ZHI: 0,
          TI: 0,
          MEI: 0,
          LAO: 0,
          show: false,
        },
        {
          numberNo: 2,
          jia: "",
          jian: "",
          DE: 0,
          ZHI: 0,
          TI: 0,
          MEI: 0,
          LAO: 0,
          show: false,
        },
        {
          numberNo: 3,
          jia: "",
          jian: "",
          DE: 0,
          ZHI: 0,
          TI: 0,
          MEI: 0,
          LAO: 0,
          show: false,
        },
      ],
      scoreList: {
        // 德育
        moralEducation: {
          DeBasicScore: 70,
          moralEducationScore: 0,
          TotalScore: 0,
        },
        // 智育
        IntellectualEducation: {
          ZhiBasicScore: 0,
          IntellectualEducationScore: 0,
          TotalScore: 0,
        },
        // 体育
        Sports: {
          TiBasicScore: 70,
          SportsScore: 0,
          TotalScore: 0,
        },
        //美育
        AestheticEducation: {
          MeiBasicScore: 70,
          AestheticEducationScore: 0,
          TotalScore: 0,
        },
        //劳育
        LaborEducation: {
          LaoBasicScore: 70,
          LaborEducationScore: 0,
          TotalScore: 0,
        },
        // 综测总分
        ComprehensiveSurveyTotalScore: 0,
        // 综测排名
        ComprehensiveSurveyRanking: "无",
        // 班长签名
        monitor: "",
        // 班主任签名
        headmaster: "",
        // 辅导员签名
        instructor: "",
        projectScore: "",
      },

      formInline: {
        SecondaryCollege:
          userInfo.grade === this.$route.params.grade
            ? userInfo?.SecondaryCollege
            : "xxx",
        className:
          userInfo.grade === this.$route.params.grade
            ? userInfo.className
            : "xxx",
        schoolYear: "xxx",
        semester: "xxx",
        studentName:
          userInfo.grade === this.$route.params.grade
            ? userInfo.studentName
            : "xxx",
        studentNo:
          userInfo.grade === this.$route.params.grade
            ? userInfo.student_Number
            : "xxx",
        grade:
          userInfo.grade === this.$route.params.grade ? userInfo.grade : "xxx",
        // input: "",
      },
      // 表头
      tableList: {
        number: "序号",
        jiafen: "加分原因",
        jianfen: "减分原因",
        de: "德",
        zhi: "智",
        ti: "体",
        mei: "美",
        lao: "劳",
      },
      yesOrNoSubmit: false,
      gradeSubmit:
        userInfo.grade === this.$route.params.grade.slice(0, 2) ? false : true,
      gradeClass:
        this.$route.params.grade.slice(0, 2) === "大四" ? true : false,
      // locationUrl: this.$route,
      infoShow: true,
      buttonShow: true,
      isProcess: false,
      isNoProcess: false,
      textarea: "",
      visible: false,
    };
  },
  created() {
    // this.scoreList = this.calculationScore;
  },
  mounted() {
    // this.formInline = this.formInline1;
    // this.gradeClass=this.gradeClass1
    if (this.$route.path.startsWith("/AdminManage")) {
      this.buttonShow = false;
      this.infoShow = false;
      this.tableData.forEach((item) => {
        item.show = true;
      });
      this.showWEI = false;
      this.getAdminData(this.$route);
    } else {
      this.showWEI = false;
    }
    if (this.$route.path.startsWith("/manage/Paid")) {
      console.log("121323=-=-", this.$route);
      this.infoShow = false;
      this.showWEI = true;
      // console.log("111111111111111");
      this.getData(this.$route);
    } else {
      this.showWEI = false;
      // console.log("222222");
    }
  },
  watch: {
    $route: {
      handler: function (to, oldVal) {
        console.log("to===", to.params.grade, oldVal);
        if (to.params.grade.slice(0, 2) === "大四") {
          this.gradeClass = true;
        } else {
          this.gradeClass = false;
        }
        if (to.path.startsWith("/AdminManage")) {
          this.getAdminData(to);
        }
        if (to.path.startsWith("/manage/Paid")) {
          this.infoShow = false;
          this.tableData.forEach((item) => {
            item.show = true;
          });
          const userInfo = JSON.parse(localStorage.getItem("userInfo"));
          this.$request
            .post("/getScoreList/getScoreItem", {
              SecondaryCollege: userInfo.SecondaryCollege,
              student_Number: userInfo.student_Number,
              grade: to.params.grade.slice(0, 2),
              className: userInfo.className,
              semester: to.params.grade.substr(3, 1),
            })
            .then(({ data }) => {
              console.log(data, "dadada====");
              if (data.data && data.code === 200) {
                this.showWEI = true;
                if (
                  data.data.isOrNoProcess &&
                  data.data.isOrNoProcess === "不通过"
                ) {
                  this.gradeSubmit = false;
                  this.studentStatus = true;
                  this.status = false;
                  this.showWEI = false;
                  if (
                    data.data.beizhuValue &&
                    data.data.beizhuValue.length > 0
                  ) {
                    this.haveStudentTextarea = true;
                    this.textarea = data.data.beizhuValue;
                  }
                } else {
                  this.haveStudentTextarea = false;
                  this.textarea = "";
                }
                if (
                  data.data.AdminProcess &&
                  data.data.AdminProcess === "审核不通过"
                ) {
                  this.isStudent = true;
                  this.studentStatus = true;
                  this.status = false;
                  this.infoShow = true;
                  this.gradeSubmit = false;
                  this.showWEI = false;
                  this.adminNoProcess = true;
                  this.adminProcess = false;
                  if (
                    data.data.adminBeizhuValue &&
                    data.data.adminBeizhuValue.length > 0
                  ) {
                    this.Admintextarea = data.data.adminBeizhuValue;
                    this.haveAdmintextarea = true;
                  } else {
                    this.Admintextarea = "";
                    this.haveAdmintextarea = false;
                    this.adminNoProcess = false;
                  }
                } else if (
                  data.data.AdminProcess &&
                  data.data.AdminProcess === "审核通过"
                ) {
                  console.log("21212121211");
                  this.adminProcess = true;
                  this.adminNoProcess = false;
                  this.studentStatus = false;
                  this.status = true;
                  this.haveAdmintextarea = false;
                  this.gradeSubmit = true;
                  this.haveStudentTextarea = false;
                  this.showWEI = false;
                } else {
                  this.status = false;
                  this.studentStatus = false;
                  this.haveAdmintextarea = false;
                  this.haveStudentTextarea = false;
                  this.gradeSubmit = true;
                  this.showWEI = true;
                  this.adminNoProcess = false;
                  this.adminProcess = false;
                }
                this.adminNoProcess = false;
                this.adminProcess = false;
                this.tableData = data.data.ScoreDetails || [];
                this.scoreList = data.data.scoreList || {};
                this.formInline =
                  {
                    SecondaryCollege: userInfo?.SecondaryCollege,
                    className: userInfo.className,
                    schoolYear: data.data.schoolYear,
                    semester: data.data.semester,
                    studentName: userInfo.studentName,
                    studentNo: userInfo.student_Number,
                    grade: data.data.grade,
                  } || {};
                return;
              }
              this.studentStatus = false;
              this.showWEI = false;
              this.status = false;
              this.tableData = [];
              this.scoreList = {
                // 德育
                moralEducation: {
                  DeBasicScore: 70,
                  moralEducationScore: 0,
                  TotalScore: 0,
                },
                // 智育
                IntellectualEducation: {
                  ZhiBasicScore: 0,
                  IntellectualEducationScore: 0,
                  TotalScore: 0,
                },
                // 体育
                Sports: {
                  TiBasicScore: 70,
                  SportsScore: 0,
                  TotalScore: 0,
                },
                //美育
                AestheticEducation: {
                  MeiBasicScore: 70,
                  AestheticEducationScore: 0,
                  TotalScore: 0,
                },
                //劳育
                LaborEducation: {
                  LaoBasicScore: 70,
                  LaborEducationScore: 0,
                  TotalScore: 0,
                },
                // 综测总分
                ComprehensiveSurveyTotalScore: 0,
                // 综测排名
                ComprehensiveSurveyRanking: "无",
                // 班长签名
                monitor: "",
                // 班主任签名
                headmaster: "",
                // 辅导员签名
                instructor: "",
              };
              this.formInline = {};
            });
        }
      },
      // 深度观察监听
      deep: true,
    },
  },
  computed: {
    // formInline1() {
    //   // console.log(location, this.$route);

    //   let userInfo = JSON.parse(localStorage.getItem("userInfo"));
    //   console.log(userInfo);
    //   if (userInfo.grade === this.$route.params.grade) {
    //     this.gradeSubmit = false;
    //     return ({
    //       SecondaryCollege: userInfo?.SecondaryCollege,
    //       className: userInfo.className,
    //       schoolYear: "xxx",
    //       semester: "xxx",
    //       studentName: userInfo.studentName,
    //       studentNo: userInfo.student_Number,
    //       grade: userInfo.grade,
    //       // input: "",
    //     });
    //   }
    // },
    // gradeClass1(){
    //   if(this.$route.params.grade==="大四"){
    //     console.log("444444444444444444444444");
    //     return true
    //   }

    // },
    calculationScore() {
      if (this.$route.path.startsWith("/manage/Paid")) {
        this.gradeSubmit = true;

        // return;
      }
      if (this.$route.path.startsWith("/AdminManage")) {
        this.gradeSubmit = true;

        // return;
      }
      return (this.scoreList = {
        // 德育
        moralEducation: {
          DeBasicScore: 70,
          moralEducationScore: this.tableData.reduce((pre, item) => {
            return (pre += Number(item.DE));
          }, 0),
          TotalScore: 0,
        },
        // 智育
        IntellectualEducation: {
          ZhiBasicScore: 0,
          IntellectualEducationScore: this.tableData.reduce((pre, item) => {
            return (pre += Number(item.ZHI));
          }, 0),
          TotalScore: 0,
        },
        // 体育
        Sports: {
          TiBasicScore: 70,
          SportsScore: this.tableData.reduce((pre, item) => {
            return (pre += Number(item.TI));
          }, 0),
          TotalScore: 0,
        },
        //美育
        AestheticEducation: {
          MeiBasicScore: 70,
          AestheticEducationScore: this.tableData.reduce((pre, item) => {
            return (pre += Number(item.MEI));
          }, 0),
          TotalScore: 0,
        },
        //劳育
        LaborEducation: {
          LaoBasicScore: 70,
          LaborEducationScore: this.tableData.reduce((pre, item) => {
            return (pre += Number(item.LAO));
          }, 0),
          TotalScore: 0,
        },
        // 综测总分
        ComprehensiveSurveyTotalScore: 0,
        // 综测排名
        ComprehensiveSurveyRanking: "无",
        // 班长签名
        monitor: "",
        // 班主任签名
        headmaster: "",
        // 辅导员签名
        instructor: "",
      });
    },
  },
  methods: {
    getAdminData(to) {
      // to.push({isPass:true})
      this.$request
        .post("/getScoreList/getScoreItem", {
          SecondaryCollege: to.query.college,
          student_Number: to.query.studentNumber,
          grade: to.query.grade,
          className: to.query.className,
          semester: to.query.Time,
        })
        .then(({ data }) => {
          console.log(data, "dadada====");
          if (data.data && data.code === 200) {
            this.adminDisabled = false;
            this.tableData = data.data.ScoreDetails || [];
            this.scoreList = data.data.scoreList || {};
            this.formInline =
              {
                SecondaryCollege: to.query.college,
                className: to.query.className,
                schoolYear: data.data.schoolYear,
                semester: data.data.semester,
                studentName: to.query.studentName,
                studentNo: to.query.studentNumber,
                grade: data.data.grade,
              } || {};
            this.textarea = data.data?.beizhuValue;
            this.isProcess = data.data.isOrNoProcess === "通过" ? true : false;
            this.isNoProcess =
              data.data.isOrNoProcess === "不通过" ? true : false;
            this.adminNoProcess =
              data.data.AdminProcess === "审核不通过" ? true : false;
            this.adminProcess =
              data.data.AdminProcess === "审核通过" ? true : false;
            return;
          }
          this.adminDisabled = true;
          this.adminNoProcess = false;
          this.adminProcess = false;
          this.tableData = [];
          this.scoreList = {
            // 德育
            moralEducation: {
              DeBasicScore: 70,
              moralEducationScore: 0,
              TotalScore: 0,
            },
            // 智育
            IntellectualEducation: {
              ZhiBasicScore: 0,
              IntellectualEducationScore: 0,
              TotalScore: 0,
            },
            // 体育
            Sports: {
              TiBasicScore: 70,
              SportsScore: 0,
              TotalScore: 0,
            },
            //美育
            AestheticEducation: {
              MeiBasicScore: 70,
              AestheticEducationScore: 0,
              TotalScore: 0,
            },
            //劳育
            LaborEducation: {
              LaoBasicScore: 70,
              LaborEducationScore: 0,
              TotalScore: 0,
            },
            // 综测总分
            ComprehensiveSurveyTotalScore: 0,
            // 综测排名
            ComprehensiveSurveyRanking: "无",
            // 班长签名
            monitor: "",
            // 班主任签名
            headmaster: "",
            // 辅导员签名
            instructor: "",
          };
          this.formInline = {};
        });
    },
    onProcess() {
      console.log(this.textarea, this.Admintextarea);
      console.log("55555555555");
      this.isProcess = true;
      this.isNoProcess = false;
      this.submit();
      this.visible = false;
    },
    onNoProcess() {
      this.isProcess = false;
      this.isNoProcess = true;
      // this.submit();
    },
    onAdminProcess() {
      this.adminNoProcess = false;
      this.adminProcess = true;
      console.log("111111111");
      this.submit();
      this.visible = false;
    },
    onAdminNoProcess() {
      this.adminNoProcess = true;
      this.adminProcess = false;
    },
    getData(to) {
      this.infoShow = false;
      this.tableData.forEach((item) => {
        item.show = true;
      });
      const userInfo = JSON.parse(localStorage.getItem("userInfo"));
      this.$request
        .post("/getScoreList/getScoreItem", {
          SecondaryCollege: userInfo.SecondaryCollege,
          student_Number: userInfo.student_Number,
          grade: to.params.grade.slice(0, 2),
          className: userInfo.className,
          semester: to.params.grade.substr(3, 1),
        })
        .then(({ data }) => {
          if (data.data && data.code === 200) {
            this.showWEI = true;
            if (
              data.data.isOrNoProcess &&
              data.data.isOrNoProcess === "不通过"
            ) {
              this.gradeSubmit = false;
              this.studentStatus = true;
              this.status = false;
              this.showWEI = false;
              if (data.data.beizhuValue && data.data.beizhuValue.length > 0) {
                this.haveStudentTextarea = true;
                this.textarea = data.data.beizhuValue;
              }
            } else {
              this.haveStudentTextarea = false;
              this.textarea = "";
            }
            if (
              data.data.AdminProcess &&
              data.data.AdminProcess === "审核不通过"
            ) {
              this.isStudent = true;
              this.studentStatus = true;
              this.status = false;
              this.infoShow = true;
              this.gradeSubmit = false;
              this.showWEI = false;
              this.adminNoProcess = true;
              this.adminProcess = false;
              if (
                data.data.adminBeizhuValue &&
                data.data.adminBeizhuValue.length > 0
              ) {
                this.Admintextarea = data.data.adminBeizhuValue;
                this.haveAdmintextarea = true;
              } else {
                this.Admintextarea = "";
                this.haveAdmintextarea = false;
                this.adminNoProcess = false;
                this.adminProcess = false;
              }
            } else if (
              data.data.AdminProcess &&
              data.data.AdminProcess === "审核通过"
            ) {
              console.log(" this.gradeSubmit = true;", 1111111);
              this.studentStatus = false;
              this.status = true;
              this.haveAdmintextarea = false;
              this.gradeSubmit = true;
              this.haveStudentTextarea = false;
              this.showWEI = false;
              this.adminNoProcess = false;
              this.adminProcess = true;
            } else {
              this.status = false;
              this.haveAdmintextarea = false;
              this.studentStatus = false;
              this.gradeSubmit = true;
              this.haveStudentTextarea = false;

              this.showWEI = true;
              this.adminNoProcess = false;
              this.adminProcess = false;
            }

            this.tableData = data.data.ScoreDetails;
            this.scoreList = data.data.scoreList;
            this.formInline = {
              SecondaryCollege: userInfo?.SecondaryCollege,
              className: userInfo.className,
              schoolYear: data.data.schoolYear,
              semester: data.data.semester,
              studentName: userInfo.studentName,
              studentNo: userInfo.student_Number,
              grade: data.data.grade,
            };
            return;
          }
          this.adminNoProcess = false;
          this.adminProcess = false;
          this.studentStatus = false;
          this.showWEI = false;
          this.status = false;
          this.tableData = [];
          this.scoreList = {
            // 德育
            moralEducation: {
              DeBasicScore: 70,
              moralEducationScore: 0,
              TotalScore: 0,
            },
            // 智育
            IntellectualEducation: {
              ZhiBasicScore: 0,
              IntellectualEducationScore: 0,
              TotalScore: 0,
            },
            // 体育
            Sports: {
              TiBasicScore: 70,
              SportsScore: 0,
              TotalScore: 0,
            },
            //美育
            AestheticEducation: {
              MeiBasicScore: 70,
              AestheticEducationScore: 0,
              TotalScore: 0,
            },
            //劳育
            LaborEducation: {
              LaoBasicScore: 70,
              LaborEducationScore: 0,
              TotalScore: 0,
            },
            // 综测总分
            ComprehensiveSurveyTotalScore: 0,
            // 综测排名
            ComprehensiveSurveyRanking: "无",
            // 班长签名
            monitor: "",
            // 班主任签名
            headmaster: "",
            // 辅导员签名
            instructor: "",
          };
          this.formInline = {};
        });
    },
    deTotal(e) {
      this.scoreList.moralEducation.TotalScore = Number(
        eval(e.target.value)
      ).toFixed(2);
    },
    zhiTotal(e) {
      this.scoreList.IntellectualEducation.TotalScore = Number(
        eval(e.target.value)
      ).toFixed(2);
    },
    tiTotal(e) {
      this.scoreList.Sports.TotalScore = Number(eval(e.target.value)).toFixed(
        2
      );
    },
    meiTotal(e) {
      this.scoreList.AestheticEducation.TotalScore = Number(
        eval(e.target.value)
      ).toFixed(2);
    },
    laoTotal(e) {
      this.scoreList.LaborEducation.TotalScore = Number(
        eval(e.target.value)
      ).toFixed(2);
    },
    handleEdit(index) {
      // console.log(index, row);
      this.tableData[index].show = !this.tableData[index].show;
      this.gradeSubmit = false;
    },
    handleDelete(index) {
      // console.log(index, row);
      const indexNumber = [index];
      this.tableData = this.tableData.filter((item, idx) => {
        return !indexNumber.includes(idx);
      });
    },
    add() {
      this.tableData.push({
        numberNo: this.tableData.length + 1,
        jia: "",
        jian: "",
        DE: 0,
        ZHI: 0,
        TI: 0,
        MEI: 0,
        LAO: 0,
        show: false,
      });
    },
    submit() {
      this.gradeSubmit = true;
      this.tableData.forEach((item) => {
        item.show = true;
      });
      // this.tableData[index].show=true
      const dataList = {
        SecondaryCollege: this.formInline?.SecondaryCollege,
        Secondarystudent: [
          {
            className: this.formInline.className,
            studentList: [
              {
                student_Number: this.formInline.studentNo,
                studentName: this.formInline.studentName,
                schoolYearList: [
                  {
                    schoolYear: this.formInline.schoolYear,
                    grade: this.formInline.grade,
                    score_item: [
                      {
                        isOrNoProcess: this.isProcess
                          ? "通过"
                          : this.isNoProcess
                          ? "不通过"
                          : undefined,
                        beizhuValue:
                          this.textarea.length > 0 && this.isNoProcess
                            ? this.textarea
                            : "",
                        AdminProcess: this.adminProcess
                          ? "审核通过"
                          : this.adminNoProcess
                          ? "审核不通过"
                          : undefined,
                        adminBeizhuValue:
                          this.Admintextarea.length > 0 && this.adminNoProcess
                            ? this.Admintextarea
                            : "",
                        yesOrNoSubmit: this.gradeSubmit,
                        semester: this.formInline.semester,
                        ScoreDetails: this.tableData,
                        scoreList: this.scoreList,
                      },
                    ],
                  },
                ],
              },
            ],
          },
        ],
      };
      this.$request
        .post("/AddStudentScore", {
          SecondaryCollege: this.formInline?.SecondaryCollege,
          student_Number: this.formInline.studentNo,
          school_year: this.formInline.schoolYear,
          grade: this.formInline.grade,
          className: this.formInline.className,
          semester: this.formInline.semester,
          dataList: dataList,
        })
        .then(({ data }) => {
          console.log("data.data-=-=--=", data.data);
          this.formInline = {
            SecondaryCollege: data?.data?.SecondaryCollege,
            className: data.data.Secondarystudent[0].className,
            schoolYear:
              data.data.Secondarystudent[0].studentList[0].schoolYearList[0]
                .schoolYear,
            semester:
              data.data.Secondarystudent[0].studentList[0].schoolYearList[0]
                .score_item[0].semester,
            studentName:
              data.data.Secondarystudent[0].studentList[0].studentName,
            studentNo:
              data.data.Secondarystudent[0].studentList[0].student_Number,
            grade:
              data.data.Secondarystudent[0].studentList[0].schoolYearList[0]
                .grade,
          };
          this.tableData =
            data.data.Secondarystudent[0].studentList[0].schoolYearList[0].score_item[0].ScoreDetails;
          this.scoreList =
            data.data.Secondarystudent[0].studentList[0].schoolYearList[0].score_item[0].scoreList;
          
          if (data.code === 200) {
            this.getData(this.$route);
            this.getAdminData(this.$route);
          }
        });

      // console.log("input", this.tableData, this.scoreList, this.formInline);
    },
    calculation() {
      if (this.$route.params.grade === "大四") {
        this.scoreList.moralEducation.TotalScore = (
          (Number(this.scoreList.moralEducation.moralEducationScore) +
            Number(this.scoreList.moralEducation.DeBasicScore)) *
          0.3
        ).toFixed(2);
        this.scoreList.IntellectualEducation.TotalScore = (
          (Number(
            this.scoreList.IntellectualEducation.IntellectualEducationScore
          ) +
            Number(this.scoreList.IntellectualEducation.ZhiBasicScore)) *
          0.4
        ).toFixed(2);
        this.scoreList.Sports.TotalScore = (
          (Number(this.scoreList.Sports.SportsScore) +
            Number(this.scoreList.Sports.TiBasicScore)) *
          0.1
        ).toFixed(2);
        this.scoreList.AestheticEducation.TotalScore = (
          (Number(this.scoreList.AestheticEducation.AestheticEducationScore) +
            Number(this.scoreList.AestheticEducation.MeiBasicScore)) *
          0.1
        ).toFixed(2);
        this.scoreList.LaborEducation.TotalScore = (
          (Number(this.scoreList.LaborEducation.LaborEducationScore) +
            Number(this.scoreList.LaborEducation.LaoBasicScore)) *
          0.1
        ).toFixed(2);
        this.scoreList.ComprehensiveSurveyTotalScore = (
          Number(this.scoreList.moralEducation.TotalScore) +
          Number(this.scoreList.IntellectualEducation.TotalScore) +
          Number(this.scoreList.Sports.TotalScore) +
          Number(this.scoreList.AestheticEducation.TotalScore) +
          Number(this.scoreList.LaborEducation.TotalScore)
        ).toFixed(2);
        return;
      }
      this.scoreList.moralEducation.TotalScore = (
        (Number(this.scoreList.moralEducation.moralEducationScore) +
          Number(this.scoreList.moralEducation.DeBasicScore)) *
        0.3
      ).toFixed(2);
      this.scoreList.IntellectualEducation.TotalScore = (
        (Number(
          this.scoreList.IntellectualEducation.IntellectualEducationScore
        ) +
          Number(this.scoreList.IntellectualEducation.ZhiBasicScore)) *
        0.5
      ).toFixed(2);
      this.scoreList.Sports.TotalScore = (
        (Number(this.scoreList.Sports.SportsScore) +
          Number(this.scoreList.Sports.TiBasicScore)) *
        0.2
      ).toFixed(2);
      this.scoreList.ComprehensiveSurveyTotalScore = (
        Number(this.scoreList.moralEducation.TotalScore) +
        Number(this.scoreList.IntellectualEducation.TotalScore) +
        Number(this.scoreList.Sports.TotalScore)
      ).toFixed(2);
    },
  },
};
</script>
<style lang="scss" scoped>
h1 {
  text-align: center;
  font-size: 24px;
}
.form {
  text-align: center;
}
.scoreForm {
  display: flex;
}
</style>